package com.bearlair.ch1;

/**
 * 实现Runnable接口，创建线程
 */
public class RunnableImpl implements Runnable {
    private int counter = 0;

    public void run() {
        counter++;
        System.out.println(this.getClass().getSimpleName() + " start:" + counter);
    }

    /**
     * 测试类
     */
    static class Starter {
        public static void main(String[] args) {
            RunnableImpl ri = new RunnableImpl();
            for (int i = 0; i < 3; i++) {
                Thread thread = new Thread(ri);
                thread.start();
            }
        }
    }
}
